Moved entry->visible into editable class. (Leave it behind deprecated for
authorOwen Taylor <otaylor@redhat.com>
Wed, 10 Feb 1999 00:39:49 +0000 (00:39 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 10 Feb 1999 00:39:49 +0000 (00:39 +0000)
Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
  entry->visible into editable class. (Leave it
  behind deprecated for compatibility)

* gtk/gtkeditable.c: If not editable->visible,
  return *'s for clipboard and selection.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkeditable.c
gtk/gtkeditable.h
gtk/gtkentry.c
gtk/gtkentry.h

index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index ae35e800c694786634c0f81127b1c1563df740a8..d5034718d3ca2fa9d96dd0a86b286e9b3f7348d3 100644 (file)
@@ -1,3 +1,12 @@
+Tue Feb  9 19:39:32 1999  Owen Taylor  <otaylor@redhat.com>
+
+        * gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
+         entry->visible into editable class. (Leave it
+         behind deprecated for compatibility)
+        
+       * gtk/gtkeditable.c: If not editable->visible,
+         return *'s for clipboard and selection.
+
 Tue Feb  9 19:11:43 1999  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkstyle.c (gtk_style_new): If we can't find
index d85743f874756805e356231cb0b933f8eafd0c27..178b5ca990fc7f2bbe5ca0d34fd12884ae46d13d 100644 (file)
@@ -75,6 +75,9 @@ static void gtk_editable_set_arg           (GtkObject        *object,
 static void gtk_editable_get_arg            (GtkObject        *object,
                                              GtkArg           *arg,
                                              guint             arg_id);
+static void *gtk_editable_get_public_chars   (GtkEditable      *editable,
+                                             gint              start,
+                                             gint              end);
 static gint gtk_editable_selection_clear     (GtkWidget        *widget,
                                             GdkEventSelection *event);
 static void gtk_editable_selection_get      (GtkWidget         *widget,
@@ -382,6 +385,7 @@ gtk_editable_init (GtkEditable *editable)
   editable->selection_end_pos = 0;
   editable->has_selection = FALSE;
   editable->editable = 1;
+  editable->visible = 1;
   editable->clipboard_text = NULL;
 
 #ifdef USE_XIM
@@ -473,6 +477,35 @@ gtk_editable_get_chars      (GtkEditable      *editable,
   return klass->get_chars (editable, start, end);
 }
 
+/*
+ * Like gtk_editable_get_chars, but if the editable is not
+ * visible, return asterisks
+ */
+static void *    
+gtk_editable_get_public_chars (GtkEditable      *editable,
+                              gint              start,
+                              gint              end)
+{
+  if (editable->visible)
+    return gtk_editable_get_chars (editable, start, end);
+  else
+    {
+      gint i;
+      gint nchars = end - start;
+      gchar *str;
+       
+      if (nchars < 0)
+       nchars = -nchars;
+
+      str = g_new (gchar, nchars + 1);
+      for (i = 0; i<nchars; i++)
+       str[i] = '*';
+      str[i] = '\0';
+
+      return str;
+    }
+}
+
 static void
 gtk_editable_set_selection (GtkEditable *editable,
                            gint      start_pos,
@@ -568,9 +601,9 @@ gtk_editable_selection_get (GtkWidget        *widget,
     {
       selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos);
       selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos);
-      str = gtk_editable_get_chars(editable, 
-                                  selection_start_pos, 
-                                  selection_end_pos);
+      str = gtk_editable_get_public_chars(editable, 
+                                         selection_start_pos, 
+                                         selection_end_pos);
       if (!str)
         return;                /* Refuse */
       length = strlen (str);
@@ -890,9 +923,9 @@ gtk_editable_real_copy_clipboard (GtkEditable *editable)
       if (gtk_selection_owner_set (GTK_WIDGET (editable),
                                   clipboard_atom,
                                   time))
-       editable->clipboard_text = gtk_editable_get_chars (editable,
-                                                          selection_start_pos,
-                                                          selection_end_pos);
+       editable->clipboard_text = gtk_editable_get_public_chars (editable,
+                                                                 selection_start_pos,
+                                                                 selection_end_pos);
     }
 }
 
index 672d7cb61b3943822dc8b0e518e3455407661d95..bf609c4327d706ff55455a31a81e5a8cfc014881 100644 (file)
@@ -51,6 +51,7 @@ struct _GtkEditable
   guint      selection_end_pos;
   guint      has_selection : 1;
   guint      editable : 1;
+  guint      visible : 1;
   GdkIC     *ic;
   GdkICAttr *ic_attr;
 
index 045566ac9dd75920abff8b4a4c821a0993272dfb..642ea264e88caf47252af6eb0a875472113cf569 100644 (file)
@@ -326,7 +326,7 @@ gtk_entry_get_arg (GtkObject      *object,
       GTK_VALUE_UINT (*arg) = entry->text_max_length;
       break;
     case ARG_VISIBILITY:
-      GTK_VALUE_BOOL (*arg) = entry->visible;
+      GTK_VALUE_BOOL (*arg) = GTK_EDITABLE (entry)->visible;
       break;
     default:
       arg->type = GTK_TYPE_INVALID;
@@ -460,7 +460,8 @@ gtk_entry_set_visibility (GtkEntry *entry,
   g_return_if_fail (entry != NULL);
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
-  entry->visible = visible;
+  entry->visible = visible ? TRUE : FALSE;
+  GTK_EDITABLE (entry)->visible = visible ? TRUE : FALSE;
   gtk_entry_recompute_offsets (entry);
   gtk_widget_queue_draw (GTK_WIDGET (entry));
 }
@@ -1344,8 +1345,8 @@ gtk_entry_draw_text (GtkEntry *entry)
       selection_end_xoffset = 
        entry->char_offset[selection_end_pos] -entry->scroll_offset;
 
-      /* if entry->visible, print a bunch of stars.  If not, print the standard text. */
-      if (entry->visible)
+      /* if editable->visible, print a bunch of stars.  If not, print the standard text. */
+      if (editable->visible)
        {
          toprint = entry->text + start_pos;
        }
@@ -1391,7 +1392,7 @@ gtk_entry_draw_text (GtkEntry *entry)
                           toprint + selection_end_pos - start_pos,
                           end_pos - selection_end_pos);
        /* free the space allocated for the stars if it's neccessary. */
-      if (!entry->visible)
+      if (!editable->visible)
        g_free (toprint);
 
       if (editable->editable)
@@ -1725,7 +1726,7 @@ gtk_entry_insert_text (GtkEditable *editable,
       for (i=start_pos; i<end_pos; i++)
        {
          entry->char_offset[i] = entry->char_offset[start_pos] + offset;
-         if (entry->visible)
+         if (editable->visible)
            {
              offset += gdk_char_width_wc (GTK_WIDGET (entry)->style->font,
                                           entry->text[i]);
@@ -1756,7 +1757,7 @@ gtk_entry_recompute_offsets (GtkEntry *entry)
   for (i=0; i<entry->text_length; i++)
     {
       entry->char_offset[i] = offset;
-      if (entry->visible)
+      if (GTK_EDITABLE (entry)->visible)
        {
          offset += gdk_char_width_wc (GTK_WIDGET (entry)->style->font,
                                       entry->text[i]);
index f29ccaaae7829c366ffe6011fa2fcd20d5568a44..ca129e783bd5f72a712294f15621294a7fa81861 100644 (file)
@@ -52,7 +52,7 @@ struct _GtkEntry
   guint16 text_length; /* length in use */
   guint16 text_max_length;
   gint    scroll_offset;
-  guint   visible : 1;
+  guint   visible : 1; /* deprecated - see editable->visible */
   guint32 timer;
   guint   button;